package com.samebuilding.service.impl;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.samebuilding.dao.FriendDAO;
import com.samebuilding.dao.FriendRequestDAO;
import com.samebuilding.domain.User;
import com.samebuilding.service.FriendService;

public class FriendServiceImpl implements FriendService {
	
	private FriendDAO friendDAO;
	private FriendRequestDAO friendRequestDAO;
	
	public FriendRequestDAO getFriendRequestDAO() {
		return friendRequestDAO;
	}

	public void setFriendRequestDAO(FriendRequestDAO friendRequestDAO) {
		this.friendRequestDAO = friendRequestDAO;
	}

	@Transactional
	public void addFriend(int userNo, int friendUserNo,int type) {
		this.friendRequestDAO.delByUid(userNo, friendUserNo);
		friendDAO.addFriend(userNo, friendUserNo,type);
	}

	@Transactional
	public void deleteFriend(int userNo, int friendUserNo) {
		friendDAO.deleteFriend(userNo, friendUserNo);
	}

	public List<User> findByType(int userNo,int type, int start, int limit) {
		return friendDAO.findByType(userNo,type, start, limit);
	}

	public FriendDAO getFriendDAO() {
		return friendDAO;
	}

	public void setFriendDAO(FriendDAO friendDAO) {
		this.friendDAO = friendDAO;
	}

	public List findAllFriend(int userNo, int start, int limit) {
		
		return this.friendDAO.findAllFriend(userNo, start, limit);
	}

	public List findAllFriendDWR(int userNo) {
		List list=this.friendDAO.findAllFriendDWR(userNo);
		return list;
	}

	public int findCountAllFriend(int userNo) {
		return this.friendDAO.findCountAllFriend(userNo);
	}

	public int findCountByType(int userNo, int type) {
		
		return this.friendDAO.findCountByType(userNo, type);
	}

	public List findAllFriend(int userNo) {
		
		return this.friendDAO.findAllFriend(userNo);
	}

	public List<User> findByType(int userNo, int type) {
		
		return this.friendDAO.findByType(userNo, type);
	}

}
